<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>

<script type="text/javascript">
	function callback_pcardRemove(id) {
		if ($("#pcard-" + id).size() > 0) {
			$("#pcard-" + id).fadeOut("slow");
		}
	}
</script>

<table class="table" width="100%" layoutH="138">
	<thead>
		<tr>
			<th align="center">序号</th>
			<th align="center">姓名</th>
			<th align="center">单位</th>
			<th align="center">职务</th>
			<th align="center">办公电话</th>
			<th align="center">手机</th>
			<th align="center">邮箱</th>
			<th align="center">地址</th>
			<th align="center">QQ</th>
			<th align="center">所属行业</th>
			<th align="center">所属项目编号</th>
			<th align="center">登记人</th>
			<th align="center">详细</th>
			<th align="center">编辑</th>
			<c:if test="${tm:inRange('ROLE_SUPER,ROLE_PROJECT_MANAGER_ASSISTANT', sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.roleKey, ',')}">
			<th align="center">删除</th>
			</c:if>
		</tr>
	</thead>
	<tbody>
		<logic:present name="datagrid">
			<logic:iterate name="datagrid" property="items" id="entity" indexId="idx">
				<tr id="pcard-${entity.id}" ${idx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
					<td>${idx+1}</td>
					<td style="text-align: left" title="${entity.fullName}">${entity.fullName}</td>
					<td style="text-align: left" title="${entity.company}">${entity.company ne null && entity.company ne '' ? tm:subString(entity.company, 25, '...') : '无'}</td>
					<td style="text-align: left" title="${entity.jobTitle}">${entity.jobTitle ne null && entity.jobTitle ne '' ? tm:subString(entity.jobTitle, 20, '...') : '无'}</td>
					<td style="text-align: left" title="${entity.officePhone}">${entity.officePhone ne null && entity.officePhone ne '' ? tm:subString(entity.officePhone, 20, '...') : '无'}</td>
					<td style="text-align: left" title="${entity.mobilePhone}">${entity.mobilePhone ne null && entity.mobilePhone ne '' ? tm:subString(entity.mobilePhone, 20, '...') : '无'}</td>
					<td style="text-align: left" title="${entity.email}">${entity.email ne null && entity.email ne '' ? tm:subString(entity.email, 20, '...') : '无'}</td>
					<td style="text-align: left" title="${entity.address}">${entity.address ne null && entity.address ne '' ? tm:subString(entity.address, 25, '...') : '无'}</td>
					<td style="text-align: center">${entity.qq ne null && entity.qq ne '' ? entity.qq : '无'}</td>
					<td style="text-align: center">${entity.industry ne null && entity.industry ne null ? entity.industry.dictKey : '无'}</td>
					<td style="text-align: center">${entity.projectNo ne null && entity.projectNo ne '' ? entity.projectNo : '无'}</td>
					<td style="text-align: center">${entity.recorderName ne null && entity.recorderName ne '' ? entity.recorderName : '无'}</td>
					<td style="text-align: center">
						<a href="app/card/personal.do?action=dialogPersonalCard&id=${entity.id}&op=view" 
							target="dialog" title="名片详细 - ${entity.fullName}" class="oplink" width="615" height="390" rel="pcard_view${entity.id}">详细</a>
					</td>
					<td style="text-align: center">
						<c:choose>
							<c:when test="${tm:inRange('ROLE_PROJECT_MANAGER_ASSISTANT', sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.roleKey, ',') || entity.recorderName ne null && entity.recorderName eq SPRING_SECURITY_LAST_USERNAME}">
								<a href="app/card/personal.do?action=dialogPersonalCard&id=${entity.id}" 
									target="dialog" title="名片编辑 - ${entity.fullName}" class="oplink" width="615" height="390" rel="pcard_edit${entity.id}">编辑</a>
							</c:when>
							<c:otherwise>
								<label style="float:none; padding:none" class="opdisabled" title="只有项目登记人才可以编辑该名片">编辑</label>
							</c:otherwise>
						</c:choose>
					</td>
					<c:if test="${tm:inRange('ROLE_SUPER,ROLE_PROJECT_MANAGER_ASSISTANT', sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.roleKey, ',')}">
					<td style="text-align: center">
						<a href="app/card/personal.do?action=actionRemovePersonalCard&id=${entity.id}" 
							target="ajaxToDo" title="确定要删除名片 '${entity.fullName}'么?" class="oplink" callback="callback_pcardRemove(${entity.id})">删除</a>
					</td>
					</c:if>
				</tr>
			</logic:iterate>
		</logic:present>
	</tbody>
</table>

<!-- Pagination -->
<div class="panelBar">
	<div class="pages">
		<span>显示</span>
		<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
			<option value="20" ${pagingBean ne null && pagingBean.pageSize eq 20 ? 'selected="selected"' : ''}>20</option>
			<option value="50" ${pagingBean ne null && pagingBean.pageSize eq 50 ? 'selected="selected"' : ''}>50</option>
			<option value="100" ${pagingBean ne null && pagingBean.pageSize eq 100 ? 'selected="selected"' : ''}>100</option>
			<option value="200" ${pagingBean ne null && pagingBean.pageSize eq 200 ? 'selected="selected"' : ''}>200</option>
		</select>
		<span>条，共${pagingBean ne null ? pagingBean.totalItems : 0}条</span>
	</div>
	<div class="pagination" targetType="navTab" totalCount="${pagingBean ne null ? pagingBean.totalItems : 0}" numPerPage="${pagingBean ne null ? pagingBean.pageSize : 20}" pageNumShown="${pagingBean ne null ? pagingBean.pageNumShown : 10}" currentPage="${pagingBean ne null ? pagingBean.currentPage : 1}"></div>
</div>
